DXL: rename buttons

Hello Falk's,

does anyone know, how renaming buttons work?

 

STB


Scaramouch - Thu Feb 27 04:05:29 EST 2014

Re: DXL: rename buttons
llandale - Fri Feb 28 13:00:30 EST 2014

I don't think you can rename a "button" after the realize.  set(dbeButton, "SomeNewLabel") fails.

But if you know ahead of time the finite set of available button labels, you can create that many Buttons, one on top of the other, and hide or show them as needed.  To demonstrate, run the following and push the button a few times.

DB db
DBE dbe1, dbe2, dbe3

void  buttonChange(DBE input_dbe)
{
   hide dbe1
   hide dbe2
   hide dbe3
   if    (input_dbe == dbe1) then show dbe2
   elseif(input_dbe == dbe2) then show dbe3
   elseif(input_dbe == dbe3) then show dbe1
   else {} // all cases covered
} // end buttonChange()

db = create("Toggle Buttons")
dbe1  = button(db, "Button 1111", buttonChange)
dbe2 = button(db, "Button 2222", buttonChange)
dbe3 = button(db, "Button 3333", buttonChange)

 dbe2 ->"top"  ->"aligned" ->dbe1
 dbe2 ->"left" ->"aligned" ->dbe1
 dbe3 ->"top"  ->"aligned" ->dbe1
 dbe3 ->"left" ->"aligned" ->dbe1
show(db)

Notice all the buttons are associated with the same callback buttonChange().  Haven't had luck with the "stacked(DBE)" command, maybe someone can show how that is used.

-Louie

Re: DXL: rename buttons
Scaramouch - Mon Mar 03 03:53:23 EST 2014

llandale - Fri Feb 28 13:00:30 EST 2014

I don't think you can rename a "button" after the realize.  set(dbeButton, "SomeNewLabel") fails.

But if you know ahead of time the finite set of available button labels, you can create that many Buttons, one on top of the other, and hide or show them as needed.  To demonstrate, run the following and push the button a few times.

DB db
DBE dbe1, dbe2, dbe3

void  buttonChange(DBE input_dbe)
{
   hide dbe1
   hide dbe2
   hide dbe3
   if    (input_dbe == dbe1) then show dbe2
   elseif(input_dbe == dbe2) then show dbe3
   elseif(input_dbe == dbe3) then show dbe1
   else {} // all cases covered
} // end buttonChange()

db = create("Toggle Buttons")
dbe1  = button(db, "Button 1111", buttonChange)
dbe2 = button(db, "Button 2222", buttonChange)
dbe3 = button(db, "Button 3333", buttonChange)

 dbe2 ->"top"  ->"aligned" ->dbe1
 dbe2 ->"left" ->"aligned" ->dbe1
 dbe3 ->"top"  ->"aligned" ->dbe1
 dbe3 ->"left" ->"aligned" ->dbe1
show(db)

Notice all the buttons are associated with the same callback buttonChange().  Haven't had luck with the "stacked(DBE)" command, maybe someone can show how that is used.

-Louie

Thank you very much.

STB

Re: DXL: rename buttons
pommCannelle - Mon Mar 03 07:52:08 EST 2014

llandale - Fri Feb 28 13:00:30 EST 2014

I don't think you can rename a "button" after the realize.  set(dbeButton, "SomeNewLabel") fails.

But if you know ahead of time the finite set of available button labels, you can create that many Buttons, one on top of the other, and hide or show them as needed.  To demonstrate, run the following and push the button a few times.

DB db
DBE dbe1, dbe2, dbe3

void  buttonChange(DBE input_dbe)
{
   hide dbe1
   hide dbe2
   hide dbe3
   if    (input_dbe == dbe1) then show dbe2
   elseif(input_dbe == dbe2) then show dbe3
   elseif(input_dbe == dbe3) then show dbe1
   else {} // all cases covered
} // end buttonChange()

db = create("Toggle Buttons")
dbe1  = button(db, "Button 1111", buttonChange)
dbe2 = button(db, "Button 2222", buttonChange)
dbe3 = button(db, "Button 3333", buttonChange)

 dbe2 ->"top"  ->"aligned" ->dbe1
 dbe2 ->"left" ->"aligned" ->dbe1
 dbe3 ->"top"  ->"aligned" ->dbe1
 dbe3 ->"left" ->"aligned" ->dbe1
show(db)

Notice all the buttons are associated with the same callback buttonChange().  Haven't had luck with the "stacked(DBE)" command, maybe someone can show how that is used.

-Louie

Hi Louie !

You can try this syntax

    dbe1  = button(db, "Button 1111", buttonChange)
    stacked(dbe1)
    dbe2 = button(db, "Button 2222", buttonChange)
    stacked(dbe2)
    dbe3 = button(db, "Button 3333", buttonChange)
    stacked(dbe3)

and remove the constrained placement ... but i can't help you if you need to "reset" the stacked feature in order to be abble to stack an other set of DBE ... maybe someone else ? ;)